import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

categories = ['A', 'B', 'C', 'D', 'E']
y1 = [25, 40, 30, 55, 15]
y2 = [15, 30, 35, 40, 30]

width = 0.35
plt.figure(figsize=(10, 6))
plt.bar(categories, y1, label='组1', width=width, color='blue')
plt.bar(categories, y2, bottom=y1, label='组2', width=width, color='green')
plt.title('堆叠柱状图')
plt.xlabel('类别')
plt.ylabel('数值')
plt.legend()
plt.show()
